package ecom.cart;

import ecom.entity.Product;
import java.io.Serializable;

/**
 *
 * @author srichard
 */
public class CartItem implements Serializable {

    Product product;
    int storeId;
    int quantity;
    double price;

    public CartItem(Product product) {
        this.product = product;
        quantity = 1;
    }
    
    public CartItem(Product product, double price) {
        this.product = product;
        this.price = price;
        quantity = 1;
    }
    
    public CartItem(Product product, double price, int storeId) {
        this.product = product;
        this.price = price;
        this.storeId = storeId;
        quantity = 1;
    }
    

    public Product getProduct() {
        return product;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getStoreId() {
        return storeId;
    }

    public void setStoreId(int storeId) {
        this.storeId = storeId;
    }

    public void incrementQuantity() {
        quantity++;
    }

    public void decrementQuantity() {
        quantity--;
    }

    public double getTotal() {
        double amount = 0;
        amount = (this.getQuantity() * this.getPrice());
        return amount;
    }
}